﻿using System;
using System.Windows.Forms;
using AppAcc.Models;

namespace AppAcc.Views.DanhMuc
{
    public partial class FormNhomTaiSanThem : DevComponents.DotNetBar.RibbonForm
    {
        //private AppAccContext db = new AppAccContext();
        private PhanMenKeToanEntities1 db = new PhanMenKeToanEntities1();
        public FormNhomTaiSanThem()
        {
            InitializeComponent();
        }

        private void BttLuu_Click(object sender, EventArgs e)
        {
            Create();
            var f = new FormNhomTaiSan();
            f.Loaddata();
        }

        private void BttThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        void Create()
        {
            try
            {
                var nts = new NhomTaiSan();
                nts.TenNhomTaiSan = txtTenNhomTaiSan.Text;
                nts.DienGiai = txtDienGiai.Text;
                db.NhomTaiSans.Add(nts);
                db.SaveChanges();
                reset();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

        }

        void reset()
        {
            txtTenNhomTaiSan.Text = "";
            txtDienGiai.Text = "";
        }
    }
}
